package com.springboot.mybatis.controller;

import com.springboot.mybatis.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;

import static com.springboot.mybatis.Test.getHoliday;

/**
 * @author sunyt
 * @date 2020/7/16 15:22
 */
@RestController
public class TestController {
    @Autowired(required = false)
    private Test test;

    @GetMapping(value = "/find")
    public String findTradeDate(String tradeDate) throws ParseException {
        String dateFlag = getHoliday(tradeDate);
        while ("1".equals(dateFlag) || "2".equals(dateFlag)) {
            String addDate = Test.addDate(tradeDate);
            dateFlag = getHoliday(addDate);
            tradeDate = addDate;
            continue;
//            System.err.println("今天是法定节假日");
        }
        return (tradeDate+"是工作日");
    }

}
